package com.hbx.utils;

import com.hbx.model.Menu;
import com.hbx.vo.login.MenuVo;
import com.hbx.vo.menu.TreeMenuVo;

/*
 * @Author:hbx
 * 
 * */
public class SubMenuUtils {
    /**
     * menu转换Submenu
     * @param menu
     * @return
     */
    public static MenuVo.SubMenu menuTransformationSubMenu(Menu menu){
        MenuVo.SubMenu subMenu = new MenuVo.SubMenu();
        subMenu.setId(menu.getId());
        subMenu.setHref(menu.getHref());
        subMenu.setIcon(menu.getIcon());
        subMenu.setTitle(menu.getTitle());
        return subMenu;
    }

    /**
     * menu转换SubMenuVo
     * @param menu
     * @return
     */
    public static TreeMenuVo menuTransformationSubMenuVo(Menu menu){
        TreeMenuVo subMenuVo = new TreeMenuVo();
        subMenuVo.setKey(menu.getId() + "");
        subMenuVo.setTitle(menu.getTitle());
        subMenuVo.setDisableCheckbox(menu.getAvailable() == 0);
        return subMenuVo;
    }

    /**
     * menu转换TreeMenuVo
     * @param menu
     * @return
     */
    public static TreeMenuVo menuTransformationTreeMenuVo(Menu menu){
        TreeMenuVo treeMenuVo = new TreeMenuVo();
        treeMenuVo.setKey(menu.getId() + "");
        treeMenuVo.setTitle(menu.getTitle());
        treeMenuVo.setDisabled(menu.getAvailable() == 0);
        return treeMenuVo;
    }
}
